package com.study.date;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class DateTest {

	public static void main(String[] args) {

		// 返回当前毫秒数
		System.out.println(System.currentTimeMillis());

		Date date = new Date();

		DateFormat format = DateFormat.getDateInstance(DateFormat.SHORT, Locale.SIMPLIFIED_CHINESE);
		DateFormat format2 = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.SIMPLIFIED_CHINESE);
		DateFormat format3 = DateFormat.getDateInstance(DateFormat.LONG, Locale.SIMPLIFIED_CHINESE);

		DateFormat format4 = DateFormat.getDateInstance(DateFormat.SHORT, Locale.ENGLISH);
		DateFormat format5 = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.ENGLISH);
		DateFormat format6 = DateFormat.getDateInstance(DateFormat.LONG, Locale.ENGLISH);

		try {
			System.out.println("format : " + format.format(new Date())); // 18-10-28
			System.out.println("format2 : " + format2.format(new Date())); // 2018-10-28
			System.out.println("format3 : " + format3.format(new Date())); // 2018年10月28日
			System.out.println("format4 : " + format4.format(new Date())); // 10/28/18
			System.out.println("format5 : " + format5.format(new Date())); // Oct
																			// 28,
																			// 2018
			System.out.println("format6 : " + format6.format(new Date())); // October
																			// 28,
																			// 2018

		} catch (Exception e) {
			e.printStackTrace();
		}

		String dateString = "2013-02-12 12:22:33";
		SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
		System.out.println("simpleDate format :" + simpleDateFormat.format(new Date()));
		try {
			System.out.println("simpleDate parse  :" + simpleDateFormat.parse(dateString));
		} catch (ParseException e) {
			e.printStackTrace();
		}

	}
}
